import router from "@/router";
import { useUserStore } from "@/store/user";

// 退出登录：删token，删动态生成的路由，删仓库数据，提示，跳转到登录页
export function logout(before?: () => void, after?: () => void) {
    const store = useUserStore();
    before && before()
    localStorage.removeItem("token");
    store.routes.forEach(item => router.removeRoute(item.name))
    store.username = "";
    store.menus = [];
    router.push("/login");
    after && after()
}